package org.lrq.voidwalker.capricornus.crawler.qqTech;

import com.geccocrawler.gecco.GeccoEngine;
import com.geccocrawler.gecco.annotation.Gecco;
import com.geccocrawler.gecco.annotation.HtmlField;
import com.geccocrawler.gecco.annotation.Request;
import com.geccocrawler.gecco.annotation.RequestParameter;
import com.geccocrawler.gecco.annotation.Text;
import com.geccocrawler.gecco.request.HttpGetRequest;
import com.geccocrawler.gecco.request.HttpRequest;
import com.geccocrawler.gecco.spider.HtmlBean;

import java.util.List;

@Gecco(matchUrl="http://tech.qq.com/l/{month}/scroll_{day}.htm", pipelines={"QQTechDailyPipeLine"})
public class QQTechDailyList implements HtmlBean {

	/**
	 * 
	 */
	private static final long serialVersionUID = -1810987433191089202L;

	@Request
	private HttpRequest request;

	@RequestParameter
	private String month;

	@RequestParameter
	private String day;




	@HtmlField(cssPath=".wrapper .main div.mod.newslist ul li a")
	private List<QQTechTitleBean> newslist;

	public HttpRequest getRequest() {
		return request;
	}

	public void setRequest(HttpRequest request) {
		this.request = request;
	}

	public List<QQTechTitleBean> getNewslist() {
		return newslist;
	}

	public void setNewslist(
			List<QQTechTitleBean> newslist) {
		this.newslist = newslist;
	}

	public String getMonth() {
		return month;
	}

	public void setMonth(String month) {
		this.month = month;
	}

	public String getDay() {
		return day;
	}

	public void setDay(String day) {
		this.day = day;
	}

	public static void main(String[] args) {
		HttpGetRequest start = new HttpGetRequest("http://tech.qq.com/l/201710/scroll_10.htm");
		
		GeccoEngine.create()
		.classpath("org.lrq.voidwalker.capricornus.crawler.qqTech")

		.start(start)
		.interval(5000)
		.run();

		GeccoEngine.create()
				.classpath("org.lrq.voidwalker.capricornus.crawler.qqTech")
				//开始抓取的页面地址
				.start(QQTechDailyPipeLine.sortRequests)
				//开启几个爬虫线程
				.thread(1)
				//单个爬虫每次抓取完一个请求后的间隔时间
				.interval(2000)
				.start();
	}
}
